<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>找回密码</title>
    <link rel="icon" href="">
    <link href="/static/css/bootstrap.min.css" rel="stylesheet">

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name" style="font-size:100px; ">随心停</h1>

            </div>
            <p>找回密码</p>
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="请输入邮箱" required="required" name="email" id="email" >
                </div>
                <div class="">
                    <input type="text" class="" placeholder="请输入验证码"  name="checkcode" id="checkcode">
                    <button class="btn btn-primary" onclick="ajax_request()" id="check">获取验证码</button>
                </div>
                <button  class="btn btn-primary block full-width m-b" onclick="ajax_request1()">找回密码</button> 
                <div><span id="result"></span></div>
        </div>
    </div>

    <!-- 全局js -->
    <script src="/static/js/jquery-2.1.1.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
<script>
var wait = 60;
var check = document.getElementById("check");
      function time() {
          if (wait == 0) {
              check.removeAttribute("disabled");
              check.innerHTML = "获取验证码";
              wait = 60;
         } else {
             check.setAttribute("disabled", true);
             check.innerHTML = wait + "秒后可以重新发送";
             wait--;
             setTimeout(function() {
                 time()
             }, 1000)
         }
     }
function ajax_request()
{
time();
var xmlhttp;
if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      // document.getElementById("result").innerHTML=xmlhttp.responseText;
      if(xmlhttp.responseText==""){ 
      }else{

      }
  }
}

var email = document.getElementById("email").value;
xmlhttp.open("GET", "/mycampus/setEmail?email=" + email, true);
xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlhttp.send();
// ajax 教程：http://www.ziqiangxuetang.com/ajax/ajax-tutorial.html
}
function ajax_request1()
{
var xmlhttp;
if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else {
    // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4 && xmlhttp.status==200) {
      // document.getElementById("result").innerHTML=xmlhttp.responseText;
      if(xmlhttp.responseText==""){ 
        document.getElementById("result").innerHTML="";
        window.location.href="/mycampus/rePassword"; 
      }else{
        document.getElementById("result").innerHTML="<font color=\"red\">"+xmlhttp.responseText+"</font>";
      }
  }
}

var email = document.getElementById("email").value;
var checkcode = document.getElementById("checkcode").value;
xmlhttp.open("GET", "/mycampus/check?email=" + email+"&&checkcode="+checkcode, true);
xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xmlhttp.send();
// ajax 教程：http://www.ziqiangxuetang.com/ajax/ajax-tutorial.html
}
</script>  

</body>

</html>